// 公共参数
const PROTOCOL = 'http'
const HOST = '127.0.0.1'
const PORT = '1018'
const baseURL = `${PROTOCOL}://${HOST}:${PORT}`
import axios from "axios"
// post请求
export const postFunc = (url, data = {}, option = { headers: "application/x-www-form-urlencoded" }) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// get请求
export const getFunc = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
// 登陆
export const loginFunc = (url, data = {}, option = { headers: "application/x-www-form-urlencoded" }) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 注册
export const registerFunc = (url, data = {}, option = { headers: "application/x-www-form-urlencoded" }) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 发送验证码
export const sendEmailFunc = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
export const uploadImageFunc = (data) => {
    // 使用axios上传图片
    return axios.post(`${baseURL}/user/modify_avatar`, data, {
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        }
    })
        .then(
            response => {
                return response.data;
            }
        )
}